
<%@ page language="java" import="java.sql.*,java.util.*" %> 
<jsp:useBean id="ViewBean" scope="page" class="ConnDB.ConnODBC"/>
<jsp:useBean id="aBean" scope="page" class="ConnDB.ConnODBC"/>  
 <%@ page contentType="text/html;charset=GBK" %>
<%@ include file="../../inc/getByteOut.jsp"%>

<%
String company=getbyte(request.getParameter("company"));
String voucher_type=getbyte(request.getParameter("voucher_type"));
String fiscal_year=getbyte(request.getParameter("fiscal_year"));
String accounting_period=getbyte(request.getParameter("accounting_period"));
String voucher_id=getbyte(request.getParameter("voucher_id"));

String num=getbyte(request.getParameter("num"));
String enter=getbyte(request.getParameter("enter"));
String checker=getbyte(request.getParameter("checker"));


String[] accounts = request.getParameterValues("account");
String[] absts = request.getParameterValues("abst");
String[] debits = request.getParameterValues("debit");
String[] credits = request.getParameterValues("credit");

String SQL="";

SQL="INSERT INTO Voucher1(company,voucher_type,fiscal_year";
SQL+=",accounting_period,voucher_id,attachment_number";
SQL+=",enter,checker) VALUES('"+company+"','"+voucher_type+"',";
SQL+=fiscal_year+","+accounting_period+","+voucher_id+",";
SQL+=num+",'"+enter+"','"+checker+"')";

aBean.executeUpdate(SQL);

ResultSet rs=aBean.executeQuery("select max(code) code from Voucher1");
String code="";
if (rs.next()){
   code=rs.getString("code");
}
rs.close();

if (accounts!=null){
 for(int i=0;i<accounts.length;i++){
   if(!accounts[i].equals("")){
    SQL="INSERT INTO Voucher2(entry_id,account_code,abstract," ;
    SQL+="natural_debit_currency,natural_credit_currency)";
SQL+= code+",'"+accounts[i]+"','"+absts[i]+"',"+debits[i]+","+credits[i]+")";
aBean.executeUpdate(SQL);
     }
}
}
%>  

</body>
</html>
